HTMLify
Max Consecutive Ones.cpp
Views: 1 | Author: cody
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { int ans = 0; int temp = 0; for(int i : nums){ if(i == 1){ temp++; } else{ if(temp>ans){ ans = temp; } temp = 0; } } if(temp>ans){ ans = temp; } return ans; } }; |